package com.dmzc.stage2.chapter9;

import java.util.Random;

/***
 * 子类只是使用父类的字段，不会引起子类的加载
 * final常量的特殊
 */
public class ActiveLoadTest {
    static class Parent {
        static {
            System.out.println("parent initiallized");
        }

        public static int y = 10;

    }

    static class Child extends Parent {
        static {
            System.out.println("child will be initialized");
        }

        public static int x = 10;
    }

    static class GlobalConstants {
        static {
            System.out.println("The GlobalConstants will be initialized.");
        }

        /**
         * 引用MAX类会被初始化，引用RANDOM不会
         */
        public final static int MAX = 100;
        public final static int RANDOM=new Random().nextInt();
    }


    public static void main(String[] args) {
        System.out.println(Child.y);
        System.out.println(GlobalConstants.MAX);
        System.out.println(GlobalConstants.RANDOM);
    }
}
